require('./Listitem.styl');
import { Boxs } from 'saltui'
import Icon from 'salt-icon'
import { Control } from 'react-keeper'
import AngleRight from 'salt-icon/lib/AngleRight';
const { HBox, Box, VBox } = Boxs;
const Remind = require('images/svg/remind.svg')
const status = ["选课未开始", "选课中", "选课已结束"];
const classtype = ["普通选课", "7选3"]
const classNames = require("classnames")
class Listitem extends React.Component {

    constructor(props) {
        super(props);
        this.state = {
        };
        this.handleClick = this.handleClick.bind(this);
    }
    handleClick() {
        if (this.props.refreshing) return;
        if (this.props.type == 1) {
            let { xuankeId } = this.props;
            Control.go('/home/electivecourses', {xuankeId})
        } else {
            Control.go('/home/selectGeneralClass')
        }

    }
    render() {
        return (
            <HBox className="listitem" vAlign="center" onClick={this.handleClick}>
                <Box flex={3}>
                    <VBox>
                        <Box flex={1}>
                            <span className="listitem-title">{this.props.title}</span>
                            {this.props.status == 1 && <span className="listitem-circle t-ML5">选课中</span>}
                        </Box>
                        <Box flex={1} className="t-MT10">
                            <Remind width='13' height='13' fill='#999' />
                            <span className="t-ML5">结束时间：</span>
                            <span className={classNames({ "march_color": this.props.status == 1 })}>{this.props.endDate}</span>
                        </Box>
                    </VBox>
                </Box>
                <Box flex={1} className="t-FAR">
                    <span className={classNames({ "march_color": this.props.status == 1 })}>{this.props.status && status[this.props.status]}</span>
                    <AngleRight width='17' height='17' fill={this.props.status == 1 ? "#0062b8" : '#999'} />
                </Box>
            </HBox>
        );
    }

    componentWillMount() {
    }

    componentDidMount() {
    }

    componentWillReceiveProps(nextProps) {
    }

    shouldComponentUpdate(nextProps, nextState) {
        return true;
    }

    componentWillUpdate(nextProps, nextState) {
    }

    componentDidUpdate(prevProps, prevState) {
    }

    componentWillUnmount() {
    }
}

module.exports = Listitem;
